// HSS.Forms.Docking.DockPanelExtender.cs
// ----------------------------------------------------------------------------
// Licensed under the MIT license
// http://www.opensource.org/licenses/mit-license.html
// ----------------------------------------------------------------------------
// HighSpeed-Solutions, LLC
// Copyright (c) 2001-2010
// ----------------------------------------------------------------------------
// File:       DockPanelExtender.cs
// Author:     HSS\gbanta
// Created:    08/12/2010
// Modified:   12/04/2010
// ----------------------------------------------------------------------------
namespace HSS.Forms.Docking
{
	#region Using Directives
	using System;
	using System.Diagnostics.CodeAnalysis;
	using System.Drawing;
	#endregion

	#region DockPanelExtender
	/// <summary>
	/// DockPanelExtender
	/// </summary>
	public sealed class DockPanelExtender
	{
		#region IDockPaneFactory
		/// <summary>
		/// IDockPaneFactory
		/// </summary>
		[SuppressMessage("Microsoft.Design", "CA1034:NestedTypesShouldNotBeVisible")]
		public interface IDockPaneFactory
		{
			/// <summary>
			/// CreateDockPane
			/// </summary>
			/// <param name="content">IDockContent</param>
			/// <param name="visibleState">DockState</param>
			/// <param name="show">bool</param>
			/// <returns>DockPane</returns>
			DockPane CreateDockPane(IDockContent content, DockState visibleState, bool show);
			/// <summary>
			/// CreateDockPane
			/// </summary>
			/// <param name="content">IDockContent</param>
			/// <param name="floatWindow">FloatWindow</param>
			/// <param name="show">bool</param>
			/// <returns>DockPane</returns>
			[SuppressMessage("Microsoft.Naming", "CA1720:AvoidTypeNamesInParameters", MessageId = "1#")]
			DockPane CreateDockPane(IDockContent content, FloatWindow floatWindow, bool show);
			/// <summary>
			/// CreateDockPane
			/// </summary>
			/// <param name="content">IDockContent</param>
			/// <param name="previousPane">DockPane</param>
			/// <param name="alignment">DockAlignment</param>
			/// <param name="proportion">double</param>
			/// <param name="show">bool</param>
			/// <returns>DockPane</returns>
			DockPane CreateDockPane(IDockContent content, DockPane previousPane, DockAlignment alignment, double proportion, bool show);
			/// <summary>
			/// CreateDockPane
			/// </summary>
			/// <param name="content">IDockContent</param>
			/// <param name="floatWindowBounds">Rectangle</param>
			/// <param name="show">bool</param>
			/// <returns>DockPane</returns>
			[SuppressMessage("Microsoft.Naming", "CA1720:AvoidTypeNamesInParameters", MessageId = "1#")]
			DockPane CreateDockPane(IDockContent content, Rectangle floatWindowBounds, bool show);
		}
		#endregion

		#region IFloatWindowFactory
		/// <summary>
		/// IFloatWindowFactory
		/// </summary>
		[SuppressMessage("Microsoft.Design", "CA1034:NestedTypesShouldNotBeVisible")]
		public interface IFloatWindowFactory
		{
			/// <summary>
			/// CreateFloatWindow
			/// </summary>
			/// <param name="dockPanel">DockPanel</param>
			/// <param name="pane">DockPane</param>
			/// <returns>FloatWindow</returns>
			FloatWindow CreateFloatWindow(DockPanel dockPanel, DockPane pane);
			/// <summary>
			/// CreateFloatWindow
			/// </summary>
			/// <param name="dockPanel">DockPanel</param>
			/// <param name="pane">DockPane</param>
			/// <param name="bounds">Rectangle</param>
			/// <returns>FloatWindow</returns>
			FloatWindow CreateFloatWindow(DockPanel dockPanel, DockPane pane, Rectangle bounds);
		}
		#endregion

		#region IDockPaneCaptionFactory
		/// <summary>
		/// IDockPaneCaptionFactory
		/// </summary>
		[SuppressMessage("Microsoft.Design", "CA1034:NestedTypesShouldNotBeVisible")]
		public interface IDockPaneCaptionFactory
		{
			/// <summary>
			/// CreateDockPaneCaption
			/// </summary>
			/// <param name="pane">DockPane</param>
			/// <returns>DockPaneCaptionBase</returns>
			DockPaneCaptionBase CreateDockPaneCaption(DockPane pane);
		}
		#endregion

		#region IDockPaneStripFactory
		/// <summary>
		/// IDockPaneStripFactory
		/// </summary>
		[SuppressMessage("Microsoft.Design", "CA1034:NestedTypesShouldNotBeVisible")]
		public interface IDockPaneStripFactory
		{
			/// <summary>
			/// CreateDockPaneStrip
			/// </summary>
			/// <param name="pane">DockPane</param>
			/// <returns>DockPaneStripBase</returns>
			DockPaneStripBase CreateDockPaneStrip(DockPane pane);
		}
		#endregion

		#region IAutoHideStripFactory
		/// <summary>
		/// IAutoHideStripFactory
		/// </summary>
		[SuppressMessage("Microsoft.Design", "CA1034:NestedTypesShouldNotBeVisible")]
		public interface IAutoHideStripFactory
		{
			/// <summary>
			/// CreateAutoHideStrip
			/// </summary>
			/// <param name="panel">DockPanel</param>
			/// <returns>AutoHideStripBase</returns>
			AutoHideStripBase CreateAutoHideStrip(DockPanel panel);
		}
		#endregion

		#region DefaultDockPaneFactory
		class DefaultDockPaneFactory : IDockPaneFactory
		{
			public DockPane CreateDockPane(IDockContent content, DockState visibleState, bool show)
			{
				return new DockPane(content, visibleState, show);
			}

			public DockPane CreateDockPane(IDockContent content, FloatWindow floatWindow, bool show)
			{
				return new DockPane(content, floatWindow, show);
			}

			public DockPane CreateDockPane(IDockContent content, DockPane prevPane, DockAlignment alignment, double proportion, bool show)
			{
				return new DockPane(content, prevPane, alignment, proportion, show);
			}

			public DockPane CreateDockPane(IDockContent content, Rectangle floatWindowBounds, bool show)
			{
				return new DockPane(content, floatWindowBounds, show);
			}
		}
		#endregion

		#region DefaultFloatWindowFactory
		class DefaultFloatWindowFactory : IFloatWindowFactory
		{
			public FloatWindow CreateFloatWindow(DockPanel dockPanel, DockPane pane)
			{
				return new FloatWindow(dockPanel, pane);
			}

			public FloatWindow CreateFloatWindow(DockPanel dockPanel, DockPane pane, Rectangle bounds)
			{
				return new FloatWindow(dockPanel, pane, bounds);
			}
		}
		#endregion

		#region DefaultDockPaneCaptionFactory
		class DefaultDockPaneCaptionFactory : IDockPaneCaptionFactory
		{
			public DockPaneCaptionBase CreateDockPaneCaption(DockPane pane)
			{
				return new DockPaneCaption(pane);
			}
		}
		#endregion

		#region DefaultDockPaneTabStripFactory
		class DefaultDockPaneStripFactory : IDockPaneStripFactory
		{
			public DockPaneStripBase CreateDockPaneStrip(DockPane pane)
			{
				return new DockPaneStrip(pane);
			}
		}
		#endregion

		#region DefaultAutoHideStripFactory
		class DefaultAutoHideStripFactory : IAutoHideStripFactory
		{
			public AutoHideStripBase CreateAutoHideStrip(DockPanel panel)
			{
				return new AutoHideStrip(panel);
			}
		}
		#endregion

		#region Constructor
		/// <summary>
		/// ctor
		/// </summary>
		/// <param name="dockPanel"></param>
		internal DockPanelExtender(DockPanel dockPanel)
		{
			_dockPanel = dockPanel;
		}
		#endregion


		DockPanel DockPanel
		{
			get { return _dockPanel; }
		} DockPanel _dockPanel;

		/// <summary>
		/// DockPaneFactory
		/// </summary>
		public IDockPaneFactory DockPaneFactory
		{
			get
			{
				if (_dockPaneFactory == null)
					_dockPaneFactory = new DefaultDockPaneFactory();

				return _dockPaneFactory;
			}
			set
			{
				if (DockPanel.Panes.Count > 0)
					throw new InvalidOperationException();

				_dockPaneFactory = value;
			}
		} IDockPaneFactory _dockPaneFactory = null;

		/// <summary>
		/// FloatWindowFactory
		/// </summary>
		public IFloatWindowFactory FloatWindowFactory
		{
			get
			{
				if (_floatWindowFactory == null)
					_floatWindowFactory = new DefaultFloatWindowFactory();

				return _floatWindowFactory;
			}
			set
			{
				if (DockPanel.FloatWindows.Count > 0)
					throw new InvalidOperationException();

				_floatWindowFactory = value;
			}
		} IFloatWindowFactory _floatWindowFactory = null;

		/// <summary>
		/// DockPaneCaptionFactory
		/// </summary>
		public IDockPaneCaptionFactory DockPaneCaptionFactory
		{
			get
			{
				if (_dockPaneCaptionFactory == null)
					_dockPaneCaptionFactory = new DefaultDockPaneCaptionFactory();

				return _dockPaneCaptionFactory;
			}
			set
			{
				if (DockPanel.Panes.Count > 0)
					throw new InvalidOperationException();

				_dockPaneCaptionFactory = value;
			}
		} IDockPaneCaptionFactory _dockPaneCaptionFactory = null;

		/// <summary>
		/// DockPaneStripFactory
		/// </summary>
		public IDockPaneStripFactory DockPaneStripFactory
		{
			get
			{
				if (_dockPaneStripFactory == null)
					_dockPaneStripFactory = new DefaultDockPaneStripFactory();

				return _dockPaneStripFactory;
			}
			set
			{
				if (DockPanel.Contents.Count > 0)
					throw new InvalidOperationException();

				_dockPaneStripFactory = value;
			}
		} IDockPaneStripFactory _dockPaneStripFactory = null;

		/// <summary>
		/// AutoHideStripFactory
		/// </summary>
		public IAutoHideStripFactory AutoHideStripFactory
		{
			get
			{
				if (_autoHideStripFactory == null)
					_autoHideStripFactory = new DefaultAutoHideStripFactory();

				return _autoHideStripFactory;
			}
			set
			{
				if (DockPanel.Contents.Count > 0)
					throw new InvalidOperationException();

				if (_autoHideStripFactory == value)
					return;

				_autoHideStripFactory = value;
			}
		} IAutoHideStripFactory _autoHideStripFactory = null;

	}
	#endregion
}